﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Linq;
using NHibernate.Criterion;
using WebPattern.DataAccess;
using WebPattern.Core.Logger;

namespace WebPattern.Core
{
    public class TestRepository : Repository<int, Test>
    {
        #region Logger
        private CustomLog4net _customLogger = new CustomLog4net(Logger);
        private CustomLog4net CLogger
        {
            get { return _customLogger; }
        }
        #endregion

        #region Constructors
        public TestRepository() : base(typeof(TestRepository)) { }
        public TestRepository(ISession session) : base(session, typeof(TestRepository)) { }
        #endregion

        #region Select
        public Test GetByName(string name)
        {
            return Session.Query<Test>()
                 .Where(val => val.Name == name)
                 .Cacheable()
                 .FirstOrDefault();
        }
        #endregion
    }
}
